<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
	
<%@ taglib prefix="c" uri="/WEB-INF/tlds/c.tld"%>
<%@ taglib prefix="spring" uri="/WEB-INF/tlds/spring.tld"%>

<c:set var="BasePath" value="${pageContext.request.contextPath}"></c:set>
<c:set var="Plugins" value="${pageContext.request.contextPath}/res/plugins"></c:set>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>品牌列表页面</title>

<link href="${Plugins}/ligerUI/skins/Aqua/css/ligerui-all.css" rel="stylesheet" type="text/css" />
<link href="${Plugins}/ligerUI/skins/ligerui-icons.css" rel="stylesheet" type="text/css" />
<script src="${Plugins}/jquery/jquery-1.3.2.min.js"	type="text/javascript"></script>
<script src="${Plugins}/ligerUI/js/ligerui.min.js" type="text/javascript"></script>
<script type="text/javascript" src="${BasePath}/res/js/ligerCommon.js"></script>

<style type="text/css">
#searchbar{
   margin-bottom: 10px;
   margin-left:15px;
  }
  .navbar {
		height: 20px;
		border-bottom: #E6E6E6 solid 1px;
		line-height: 20px;
	}
.l-button-search {
	width: 50px;
	margin-left: 10px;
	padding-bottom: 2px;
	display: inline;
}
</style>
</head>
<body style="padding:6px; overflow:hidden;">
<div id="searchbar"><br>
<div class="navbar">
		<span>您当前的位置：</span>
		商品管理 &gt; 品牌列表
</div>
<br />
<form action="#" name="queryForm" id="queryForm" method="POST" >
品牌名称：<input type="text" id="brandName" name="brandName" value="${brand.brandName}" />&nbsp;
         <input type="submit" id="btnSearch" value="查询" class="l-button-search" />
           <input type="button" id="btnReset" value="重置" class="l-button-search" />
</form>
<br />
<div id="maingrid" style="margin:0; padding:0"></div>
  <div style="display:none;">
  <!-- 展示列表数据  -->
</div>



<script>
    var basePath='${BasePath}';
    var grid = null;
	
    $(function () {
    	 // 重置
        $("#btnReset").click(function(){
    		$('#searchbar :input').not(':submit, :button, :reset').val('').removeAttr('checked').removeAttr('selected');
    	});
    	
        grid = $("#maingrid").ligerGrid({
            columns: [
            { display: '品牌名称', name: 'brandName'},
            { display: '品牌网址', name: 'brandUrl'},
            { display: '品牌描述', name: 'description'},
            { display: '操作', isSort: false, render: function (rowdata, rowindex, value){
               	var  h = "<a href='javascript:updateBrand(" + rowindex + ")'>修改</a> ";
               	h += "<a href='javascript:deleteBrand(" + rowindex + ")'>删除</a> ";
                return h;
            	}
            }
            ], 
            pageSize:30,
            width: '100%',
            height: '100%',
            dataType: 'server', 
            dataAction: 'server',
            pagesizeParmName: 'pageSize',
			parms: [
                    {name: "brandName", value:$("#brandName").val()},
            	],
			url: "list_brand.do",
			toolbar: toolbar
        });
    });
	
	var toolbar = '';
    toolbar = {
    	items: [
    			{ text: "新增品牌", click: addBrand, icon: "add" }
        		]
       		 };
    
	
/**
 * 新增品牌信息
 */
function addBrand(){
		var url=basePath+'/product/brandmgt/to_add_brand.do';
    	url+="?pTabid="+WIN_TAB.getSelectedTabItemID();
    	window.parent.f_addTab('新增品牌','新增品牌',url);
}
 
/**
 * 修改品牌信息
 */
function updateBrand(rowindex){
	 var brandNo=grid.getData()[rowindex].brandNo;
	 
      var url=basePath+'/product/brandmgt/to_update_brand.do?brandNo='+brandNo;
      url+="&pTabid="+WIN_TAB.getSelectedTabItemID();
	  window.parent.f_addTab('修改品牌','修改品牌',url);
}

function deleteBrand(rowindex) {
	var brandNo=grid.getData()[rowindex].brandNo;
	$.ligerDialog.confirm('确定删除',
		function(yes) {if (yes) {
			$.post(
					basePath+ '/product/brandmgt/deleteBrand.do',
					{brandNo : brandNo},
					function(data) {
						if (data == 'success') {
							window.parent.f_tip('删除成功');
							window.location.reload();
						} else if (data == 'fail') {
							window.parent.f_tip('删除失败');
						}else{
							window.parent.f_tip(data);
						};
					}
			);
		};
	});
}

</script>
	
</body>
</html>